home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / osr5 / sco / scripts / zedit < prev   
Encoding:
Text File  |  1997-08-26  |  904 b   |  31 lines

  1. #!/bin/sh
  2. # @(#) zedit.sh 1.0 94/01/14
  3. # 94/01/14 john h. dubois iii (john@armory.com)
  4.  
  5. VISUAL=${VISUAL:-$EDITOR}
  6. VISUAL=${VISUAL:-vi}
  7. # If a filename ending in .Z is given, strip off the .Z with expr.
  8. # This way, a compressed filename can be given with or without the .Z
  9. case "$1" in
  10. *.Z)
  11.     file=`expr "$1" : '\(.*\)\.Z$'`
  12.     ;;
  13. *)
  14.     file=$1
  15.     ;;
  16. esac
  17. # If the filename ended in .Z, OR the given filename does not exist and the
  18. # given filename with .Z appended does, it's probably compressed.
  19. # So, try uncompressing it.  If the uncompress succeeds (compress exits 0,
  20. # and after running uncompress the file without .Z exists),
  21. # edit the uncompressed file & then recompress it.
  22. # If any of the conditions fails, just edit the file.
  23. if [ "$1" != "$file" -o ! -f "$1" -a -f "$1.Z" ] && uncompress "$file.Z" &&
  24. [ -f "$file" ]
  25. then
  26.     $VISUAL "$file"
  27.     compress "$file"
  28. else
  29.     $VISUAL "$1"
  30. fi
  31.